package model.player;

/**
 * the enumeration of PlayerColor
 * 
 * All possible playercolors are defined with the RGB worth...
 * 
 * @author Konry
 * 
 */

public enum PlayerColor {
	BLUE(255), RED(16711680), GREEN(65280), ORANGE(16747520), YELLOW(16776960), BROWN(
			9127187), BLACK(0), WHITE(16777215);
	/** The value representing player color's enumeration. */
	int value;

	/**
	 * Change a playerColor to an Integer.
	 * 
	 * @return the RGB worth of the enumeration
	 */
	public int toInt() {
		return value;
	}

	/**
	 * Returns to a RGB worth a enum
	 * 
	 * @param i
	 *            an Integer to check
	 * @return a enum of the Integer
	 */
	public static PlayerColor toSerialInt(int i) {
		switch (i) {
		case 255:
			return BLUE;
		case 16711680:
			return RED;
		case 65280:
			return GREEN;
		case 16747520:
			return ORANGE;
		case 16776960:
			return YELLOW;
		case 9127187:
			return BROWN;
		case 0:
			return BLACK;
		case 16777215:
			return WHITE;
		default:
			return BLUE;
		}
	}

	/**
	 * Returns the PlayerColor by an integer value, which represents the
	 * position of a color in this enumeration.
	 * 
	 * @param i
	 *            number of PlayerColor Enum on iteration.
	 * @return The PlayerColor to return.
	 */
	public static PlayerColor getPlayerColorOnPosition(int pos) {

		switch (pos) {
		case 0:
			return BLUE;
		case 1:
			return RED;
		case 2:
			return GREEN;
		case 3:
			return ORANGE;
		case 4:
			return YELLOW;
		case 5:
			return BROWN;
		case 6:
			return BLACK;
		case 7:
			return WHITE;
		default:
			return BLUE;
		}
	}

	private PlayerColor(int value) {
		this.value = value;
	}
}
